package com.lianzhihui.minitiktok.ui

import android.content.Intent
import android.os.Handler
import com.bumptech.glide.Glide
import com.echofeng.common.ui.base.BaseNoRestartActivity
import com.echofeng.common.utils.AESCBCCrypt2
import com.echofeng.common.utils.LogUtil
import com.lianzhihui.minitiktok.bean.user.LoginResponse
import com.lianzhihui.minitiktok.config.AppConstants
import com.lianzhihui.minitiktok.config.AppStatusManager
import com.lianzhihui.minitiktok.presenter.LoginPresnterImp
import com.lianzhihui.minitiktok.ui.account.ui.login.LoginActivity
import com.lianzhihui.minitiktok.view.LoginView
import com.lianzhihui.onlyleague.R
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : BaseNoRestartActivity(),LoginView {
    private lateinit var loginPresnterImp: LoginPresnterImp

    override fun getLayoutId(): Int {
        return R.layout.activity_splash;
    }

    override fun initView() {
//        LogUtil.debug("AESCBCCrypt:", AESCBCCrypt2.aesDecrypt("HNam3zbIG0j2EAcDBfmoayeCIzOsp 4qjfSAznf /qP8Edqz374Ri9kreq6dSSGYZZj jRrelI2XuccV8Y/5rcfmVixsLjzEvu2Gx4PM554ZgF9 wrF4UJ2aPY8PquzioQJkcPSg/K2B3yLBWKTYxvbHeLLhESiZX4kHInrvCvs=", "X5HCC6sPrfyKJnA4nC3jPPMRQNKPQBmf"))
        loginPresnterImp = LoginPresnterImp(this,this)
        showLoading("登录中...")
        loginPresnterImp.doLogin();
    }
    override fun initData() {
    }

    override fun setSuccess(o: Any?) {
    }

    override fun setFailure(o: Any?) {
        dismissLoading()
    }

    override fun setLoginSuccess(data: LoginResponse) {
        dismissLoading()
//        Glide.with(this).load(data.startup.cover).into(iv_cover)
        Handler().postDelayed({
            AppStatusManager.getInstance().setAppStatus(AppConstants.AppStatus.STATUS_NORMAL)
            val intent = Intent(this@SplashActivity, MainActivity::class.java)
            startActivity(intent)
            finish()
        }, AppConstants.AppStatus.DELAY_MILLIS)
    }

}